################################################
#         Generic Makefile Template
#  When using, need to set up some variables,
#   the condition and the file list
#  			Author: Yuan Hong
################################################

CC      = g++
CFLAGS += -g
CFLAGS += -Wall
CFLAGS += -O0
CFLAGS += -D_REENTRANT

#CFLAGS += -Wno-unused-variable
#CFLAGS += -Wno-unused-but-set-variable

## 目标可执行文件 ## 相关目标文件列表
TARGET = nets 
MIDDLE = main.o yhdaemon.o yhsocket.o yhargs.o yhservice.o iokeyboard.o ioudp.o iotcp.o yhevent.o yherror.o

SYS_SHARED_LIBS += -lpthread
STATIC_COM_ARGS +=

.PHONY: all clean clear cmake remake

#strip $(LIB_SO)

## 信息显示控制
HINT =
CONT =
ifeq  "${CC}" "g++"
CCOM = $(HINT) printf ' \e[34mG++\e[m \e[33m%s\e[m\n' $@
else
CCOM = $(HINT) printf '  \e[34mCC\e[m \e[33m%s\e[m\n' $@
endif
LINK = $(HINT) printf '\e[31mLINK\e[m \e[32m%s\e[m\n' $@

CCOM =
LINK =
CONT =

## 编译命令 ##
COMMON_STATIC = $(CONT) $(CC) $(CFLAGS) $^ $(SYS_SHARED_LIBS) $(STATIC_COM_ARGS) -o $@

## 目标文件编译 ##
.c.o:
	$(CCOM)
	$(CONT) $(CC) -c $(CFLAGS) $< -o $@

all: $(TARGET)

$(TARGET): $(MIDDLE) $(LIBMDO)
	$(LINK)
	$(COMMON_STATIC)

clear:
	clear

cmake:
	make clear
	make all

remake:
	make clear
	make clean
	make all

clean:
	rm -rf $(TARGET) $(MIDDLE) $(LIB_SO) $(LIBMDO) -rf
